calculate magnitude 3d vector